package com.woniu.zsd.waste.mapper;

import com.woniu.zsd.waste.entity.WasteType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import zsd.waste.form.AddWasteTypeForm;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-03-27
 */
public interface WasteTypeMapper extends BaseMapper<WasteType> {

    @Select("select * from zsd_waste.waste_type")
    List<WasteType> selWasteType();

    @Select("SELECT COUNT(*) FROM zsd_waste.waste_type WHERE waste_type_name = #{wasteTypeName}")
    int countByWasteTypeName(@Param("wasteTypeName") String wasteTypeName);

    @Insert("INSERT INTO zsd_waste.waste_type (waste_type_name, price, price_util) VALUES (#{wasteTypeName}, #{price}, #{priceUtil})")
    int insertWasteType(AddWasteTypeForm awtf);

    @Update("UPDATE zsd_waste.waste_type SET waste_type_name = #{wasteTypeName}, price = #{price}, price_util = #{priceUtil} WHERE id = #{id}")
    int updateWasteType(WasteType wasteType);

    @Delete("DELETE FROM zsd_waste.waste_type WHERE id = #{id}")
    int deleteWasteType(@Param("id") Integer id);

    @Select("SELECT * FROM zsd_waste.waste_type WHERE id = #{id}")
    WasteType getWasteTypeById(@Param("id") Integer id);

    @Select("SELECT * FROM zsd_waste.waste_type WHERE waste_type_name LIKE CONCAT('%', #{name}, '%')")
    WasteType getWasteTypeByName(@Param("name")String name);

}